﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Database
{
    public class DatabaseFactory
    {
        public static IDatabase CreateDatabase()
        {
            IDatabase db = null;
            string NameSpace = MethodBase.GetCurrentMethod().DeclaringType.Namespace;
            string ClassName = ConnectionString.DbProviderClass;
            db = (IDatabase)Activator.CreateInstance(Type.GetType(NameSpace + "." + ClassName));
            return db;
        }
        public static IDatabase CreateDatabase(string iConnectionString)
        {
            IDatabase db = null;
            string NameSpace = MethodBase.GetCurrentMethod().DeclaringType.Namespace;
            string ClassName = ConnectionString.DbProviderClass;
            db = (IDatabase)Activator.CreateInstance(Type.GetType(NameSpace + "." + ClassName), new string[] { iConnectionString });
            return db;
        }
    }
}
